import request from "@/network/request.js";
import {
    Dialog
} from 'vant';
let headers = {
    'auth': localStorage.getItem('token')
}
let uid = JSON.parse(localStorage.getItem('userInfo')).id;
let time=0
function GetShopList() {

        return request({
            url: '/shopcar/query',
            method: 'post',
            data: {
                uid: uid
            },
            headers
        }).then(res=>{ 
            if(res.data.message=="success"){
              
               
                    res.data.table.forEach(e=>{
                        e.isCheck=true
                    })
              
               localStorage.setItem('shopCar',JSON.stringify(res.data.table))
             }
        })
    
    
}

function AddShopCar(data) {
    data.uid = uid
    return request({
        url: '/shopcar/add',
        method: 'post',
        data: data,
        headers
    })
}

function DelShopCar(data) {
    data.uid = uid
    return request({
        url: '/shopcar/delete',
        method: 'post',
        data: data,
        headers
    })
}

function ChangeShopCar(data) {
    data.uid = uid
    
    return request({
        url: '/shopcar/changenumber',
        method: 'post',
        data: data,
        headers
    })
}
function DelShopCarList(data){
    data.uid = uid
    return request({
        url: '/shopcar/deletelist',
        method: 'post',
        data: data,
        headers
    })
}
export {
    GetShopList,
    AddShopCar,
    DelShopCar,
    ChangeShopCar,
    DelShopCarList
}